/*
 * DisplayParticipantsService.java
 *
 * Created on 15 March 2006, 00:04
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package web.services;
//import business.pojos.Meeting;
import java.util.ArrayList;
import java.util.Collection;
import se392.ateam2006.meetingmgmt.meeting.MeetingEntity;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import web.util.BusinessFacadeDelegate;

/**
 *
 * @author Chris
 */
public class DisplayParticipantsService extends DisplayService {
    
    /** Creates a new instance of DisplayParticipantsService */
    
    public DisplayParticipantsService()  {
    }
    
    public String executePreDispatch(HttpServletRequest request,
            ServletContext context)
            throws Exception {
        HttpSession session = request.getSession();
        String meetingId = request.getParameter(Service.MEETING_ID);
        BusinessFacadeDelegate delegate = this.getDelegate(request.getSession());
        MeetingEntity meeting = delegate.getMeeting(meetingId);
        request.getSession().setAttribute(Service.ATTRIBUTE_MEETING, meeting);
        
        Collection<MeetingEntity> meetings = delegate.getUserMeetings(delegate.getLoggedInUser());
        Collection<String> meetingNames = new ArrayList<String>();
        for(MeetingEntity meetingEnt: meetings) {
            meetingNames.add(meetingEnt.getId());
        }
        session.setAttribute(MEETING_PART_LIST, meetingNames);
        return "update";
        //request.getSession().setAttribute("meetingUid", uid);
    }
    
    public void executePostDispatch(HttpServletRequest request,
            ServletContext context)
            throws Exception {
        request.setAttribute(Service.ATTRIBUTE_MEETING, null);
    }
}
